﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Hands.FileCache
{
    public class File
    {
        private readonly string fileName = null;
        private readonly string fileType = null;
        private MemoryStream content = null;

        internal File(string fileName, string fileType, string path)
        {
            this.fileName = fileName;
            this.fileType = fileType;
            readFile(path);
        }

        private void readFile(string path)
        {
            try
            {
                byte[] bytes = System.IO.File.ReadAllBytes(path);
                content = new MemoryStream();
                content.Write(bytes, 0, bytes.Length);
            }
            finally
            {
                content.Close();
            }
        }

        internal string FileName
        {
            get
            {
                return fileName;
            }
        }

        public string FileType
        {
            get
            {
                return fileType;
            }
        }

        public MemoryStream Content
        {
            get
            {
                return content;
            }
        }
    }
}
